package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.GreenPointDao;
import cn.topevery.garden.entity.po.GreenPoint;
import cn.topevery.garden.entity.query.GreenPointQuery;
import cn.topevery.garden.entity.vo.GreenPointVO;

import cn.topevery.garden.entity.vo.PointVO;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.DataFillHelper;
import hw.topevery.framework.db.CommandType;
import hw.topevery.framework.db.DataReader;
import hw.topevery.framework.entity.DbCsp;
import hw.topevery.framework.entity.Value;
import hw.topevery.framework.entity.KeyValue;
import hw.topevery.framework.enums.DbTypeEnum;
import hw.topevery.framework.util.LogUtil;
import hw.topevery.framework.db.DbScriptHelper;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.UUID;

/**
 * 样点表
 *
 * @author code-generate
 * @date 2023-11-17
 */
@Repository
public class GreenPointDaoImpl extends BaseDaoImpl<GreenPoint> implements GreenPointDao {
    @Override
    public <P extends DbCsp> List<GreenPoint> getSearch(P para) {
        return null;
    }



    @Override
    public DataPager<GreenPointVO> listPage(GreenPointQuery query) {
        String table = "t_green_point tgp";

        String columns = "tgp.*";

        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tgp.c_id desc");
        sqlQueryMate
                .where(true, "tgp.c_db_status", ScriptConditionEnum.Eq, 0)
        ;

        return getDataPager(sqlQueryMate, pageSize, pageIndex, GreenPointVO.class);
    }

    @Override
    public GreenPoint getEntityByColumn(String key,String value){
        KeyValue<String> map=new KeyValue<>();
        map.key=key;
        map.value=value;
        return getEntityByColumnEqValue(map);
    }

    @Override
    public DataPager <GreenPointVO> getBySectionId(GreenPointQuery query) {
        String table = "t_green_point tp";
        String columns = "tp.*";
        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;
        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns);
        sqlQueryMate.where(true, "c_db_status", ScriptConditionEnum.Eq, 0)
                .where(query.getSectionId()!=null, "c_section_id", ScriptConditionEnum.Eq, query.getSectionId());
        return getDataPager(sqlQueryMate, pageSize, pageIndex, GreenPointVO.class);
    }
}
